﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Linq;
using System.Xml;

/// <summary>
/// Summary description for MyTempEditInShortTime
/// </summary>
public class MyTempEditInShortTime
{
	public MyTempEditInShortTime()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public string getallowTempUnclockCN(System.Web.UI.Page page)
    {
        string de = "";
        try
        {
            string path = page.Server.MapPath(@"~/Upload/xml");
            string full_path = "" + path + "/allowTempUnclockCN.xml";
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(full_path);

            XmlNodeList nodeList = xmlDoc.SelectNodes("/Root");

            // timelast
            //nodeList[0].ChildNodes[0].InnerText = "ASP.NET";
            string timelast = nodeList[0].SelectSingleNode("allowTempUnclockCN").InnerText;
            de = (timelast);
        }
        catch
        {
            writeallowTempUnclockCN(page);
        }
        return de;
    }
    public bool writeallowTempUnclockCN(System.Web.UI.Page page)
    {
        bool rs = false;
        try
        {
            XDocument doc = new XDocument(
            new XElement("Root",
                new object[] { 
                new XElement("allowTempUnclockCN", "")
            }
            )
            );
            string path = page.Server.MapPath(@"~/Upload/xml");
            string full_path = "" + path + "/allowTempUnclockCN.xml";
            if (System.IO.File.Exists(full_path))
            {
                System.IO.File.Delete(full_path);
            }
            doc.Save(full_path);
            rs = true;
        }
        catch { }
        return rs;
    }
}